#!/usr/bin/python

import commands, glob, os

# Common file, for both executables and Python Interface
#common_files = """calls annotate ped phenotype randutil util""
common_files = """geno print"""

def pyversion():
        pystr = commands.getoutput('python -V')
        version = pystr.split(' ')[1]
        major, minor = version.split('.')[:2]
        return major + '.' + minor

common_base = Split(common_files)
common = [f + ".cpp" for f in common_base]
common_obj = [f+".o" for f in common_base]

# For Python interface only
pif_conv = Split("cppvec_conv cppmap_conv cppset_conv cppunicode_conv")
pif_conv_files = [t+"_pif.cpp" for t in pif_conv]

pif = Split("geno")
pif_files = [t+"_pif.cpp" for t in pif]

# Boost Python Environment
boost_python_env = Environment(
	#CXX="g++-4.4",
	CPPPATH=["/usr/include/python"+pyversion(), "."],
	CXXFLAGS='-ftemplate-depth-100 -fPIC -Wall -Werror -pedantic -pipe -O3 -ffast-math -march=opteron',
	#CXXFLAGS='-ftemplate-depth-100 -fPIC -Wall -pedantic -O0 -g',
	CPPDEFINES=['BOOST_PYTHON_DYNAMIC_LIB'],
	LIBPATH=["/usr/lib/python"+pyversion()+"/config"],
	LIBS=["python"+pyversion(), "m", "boost_python"],
	SHLIBPREFIX="", #gets rid of lib prefix
	SHOBJSUFFIX = ".bpo"
	)

test_env = Environment(
	#CXX="g++-4.4",
	CXXFLAGS='-Wall -Werror -pedantic -O0 -g',
	)

# Build boost python module
boost_python_env.SharedLibrary(target='genocpp', source = common + pif_conv_files + pif_files)
test_env.Program(target='geno_test', source = common + ["geno_test.cpp"])
